import { useMenusStore } from "@/stores/menus";


export function permisson() {
  const menusStore = useMenusStore();

  return {
    mounted(el, binding) {

      // console.log(menusStore.btnsPremissan, el, binding);

      if (!menusStore.btnsPremissan.includes(binding.value)) {
        el.style.display = "none";
        // 或者直接移除元素
        // el.parentNode.removeChild(el)
      }
    },

    update(el, binding, vnode, oldVnode) {
      // console.log(menusStore.btnsPremissan, el, binding);

      const hasPermission = menusStore.btnsPremissan.includes(binding.value);

      // 根据用户是否有权限来显示或隐藏元素
      el.style.display = hasPermission ? "block" : "none";
    },
  };
}

// export default {
//   mounted(el, binding) {
//     const menusStore = useMenusStore()

//     console.log(menusStore.btnsPremissan, el, binding);

//     if (!menusStore.btnsPremissan.includes(binding.value)) {
//       el.style.display = 'none'
//       // 或者直接移除元素
//       // el.parentNode.removeChild(el)
//     }
//   },

// }
